﻿using OnlineLearningSystem.IRepository;
using OnlineLearningSystem.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnlineLearningSystem.Repository
{
    public class BatchRepository : IBatchRepository
    {
        private readonly AppDbContext _context;

        public BatchRepository(AppDbContext context)
        {
            _context = context;
        }

        public void Create(Batch entity)
        {
            _context.Batchs.Add(entity);
            _context.SaveChanges();
        }

        public void Delete(Batch course)
        {
            _context.Batchs.Remove(course);
            _context.SaveChanges();
        }

        public Batch Get(Func<Batch, bool> wherelambda)
        {
            return _context.Batchs.Where(wherelambda).FirstOrDefault();
        }

        public List<Batch> GetAll()
        {
            return _context.Batchs.ToList();
        }

        public void Update(Batch course)
        {
            _context.Batchs.Update(course);
            _context.SaveChanges();
        }
    }
}
